package com.kingbi.system.userRole.dao;

import java.util.ArrayList;

import com.kingbi.system.userRole.model.UserRoleModel;

public class UserRoleQuery
{
    StringBuilder search_query_bud;

    StringBuilder search_count_bud;

    StringBuilder temp_bud;
    
    Object[] params ;
    
    ArrayList paramList;

    public UserRoleQuery()
    {
        super();
        this.search_query_bud = new StringBuilder();
        this.search_count_bud = new StringBuilder();
        search_query_bud
                .append("from com.kingbi.system.userRole.model.UserRoleModel userRole where 1=1");
        search_count_bud
                .append("select count(*) from com.kingbi.system.userRole.model.UserRoleModel userRole where 1=1");
    }

    public UserRoleQuery(StringBuilder search_query_bud, StringBuilder search_count_bud,
            StringBuilder temp_bud)
    {
        super();
        this.search_query_bud = new StringBuilder();
        this.search_count_bud = new StringBuilder();
        search_query_bud
                .append("from com.kingbi.system.userRole.model.UserRoleModel userRole where 1=1");
        search_count_bud
                .append("select count(*) from com.kingbi.system.userRole.model.UserRoleModel userRole where 1=1");
    }

    public void doSearchQuery(UserRoleModel userRoleModel)
    {
        temp_bud = new StringBuilder();
        paramList = new ArrayList();
       
           if(userRoleModel.getUserRoleID()!=0) 
    { 
        temp_bud.append(" and userRole.userRoleID=?"); 
         paramList.add(userRoleModel.getUserRoleID());
    } 
    if(userRoleModel.getUserId()!=null &&  !userRoleModel.getUserId().equals("") && !userRoleModel.getUserId().equals("null")) 
    { 
        temp_bud.append(" and userRole.userId=?"); 
         paramList.add(userRoleModel.getUserId().trim());
    } 
    if(userRoleModel.getRoleCode()!=null &&  !userRoleModel.getRoleCode().equals("") && !userRoleModel.getRoleCode().equals("null")) 
    { 
        temp_bud.append(" and userRole.roleCode=?"); 
         paramList.add(userRoleModel.getRoleCode().trim());
    } 


        if(paramList!=null && paramList.size()>0)
        {
            params = new Object[paramList.size()];
            for(int i=0;i<paramList.size();i++)
            {
                params[i] = paramList.get(i);
            }
        }
        
        if(temp_bud!=null && temp_bud.length()>0)
        {
            search_query_bud.append(temp_bud.toString());
            search_count_bud.append(temp_bud.toString());
        }
       
    }

    public StringBuilder getSearch_query_bud()
    {
        return search_query_bud;
    }

    public void setSearch_query_bud(StringBuilder search_query_bud)
    {
        this.search_query_bud = search_query_bud;
    }

    public StringBuilder getSearch_count_bud()
    {
        return search_count_bud;
    }

    public void setSearch_count_bud(StringBuilder search_count_bud)
    {
        this.search_count_bud = search_count_bud;
    }

    public StringBuilder getTemp_bud()
    {
        return temp_bud;
    }

    public void setTemp_bud(StringBuilder temp_bud)
    {
        this.temp_bud = temp_bud;
    }

    public Object[] getParams()
    {
        return params;
    }

    public void setParams(Object[] params)
    {
        this.params = params;
    }

    
   
}